<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<jsp:include page="../header.jsp">
	<jsp:param value="组织-部门管理" name="title" />
</jsp:include>
<link href="static/css/total.css" rel="stylesheet" type="text/css">
<link href="static/css/teacher.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
	$(function() {
		$('.selection.dropdown,select.dropdown').dropdown();
	});
	
	function dow(){
		$('.ui.labeled.icon.sidebar')
			.sidebar('setting', 'transition','overlay')
			.sidebar('toggle');
	}
</script>
</head>
<body>
	<jsp:include page="../menu/manage_menu.jsp"></jsp:include>
	<div class="teacher-content">
		<form method="post" class="ui form create-form">

			<c:choose>
				<c:when test="${empty d }">
					<div class="field">
						<label>请输入创建的部门名称</label> <input type="text" name="deptName"
							value="${param.deptName }">
					</div>
					<div class="field">
						<label>上属部门</label>
						<div class="ui selection dropdown">
							<input type="hidden" name="parentDept" value="${param.deptName }">
							<i class="dropdown icon"></i>
							<div class="default text" data-value="${param.parentId }" >请选择部门</div>
							<div class="menu">
								<div class="item none_dept" data-value="">无</div>
								<c:forEach items="${allDeptList }" var="dept">
									<div class="item" data-value="${dept.id }">${dept.deptName }</div>
								</c:forEach>
							</div>
						</div>
					</div>
				</c:when>
				<c:otherwise>
					<div class="field">
						<input type="hidden" name="id" value="${d.id }"> <label>新的部门名称</label>
						<input type="text" name="deptName" value="${d.deptName}">
					</div>
					<div class="field">
						<label>上属部门</label>
						<div class="ui selection dropdown">
							<input type="hidden" name="parentDept" value="${d.parentId }">
							<i class="dropdown icon"></i>
							<c:choose >
							<c:when test="${dept.parentId!=null }">
								<div class="default text" data-value="${dept.parentId }">${d.parentDeptName}</div>
							</c:when>
							<c:otherwise>
							<div class="default text" data-value="${dept.parentId }">请选择部门</div>
							</c:otherwise>
							</c:choose>
						
							<div class="menu">
								<div class="item none_dept" data-value="">无</div>
								<c:forEach items="${NotContainsSelfAndSonDeptList }" var="dept">
									<div class="item" data-value="${dept.id }">${dept.deptName }</div>
								</c:forEach>
							</div>
						</div>
					</div>
				</c:otherwise>
			</c:choose>
			<div class="field">
				<label>部门经理</label> <input type="text" name="deptManager"
					<c:choose>
					<c:when test="${d.deptManager==null}">
					value="${param.deptManager }"
					</c:when>
					<c:otherwise>
					value="${d.deptManager }"
					</c:otherwise>
					</c:choose>>
			</div>
			<button class="ui button" type="submit">${empty d ?'创建':'保存' }</button>
			<span>${erro}</span>
		</form>
	</div>
</body>
</html>